package com.jackrain.nea.wms.mapper;

import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

@Mapper
@Repository
public interface WmsSqlMapper {

    @Select("SELECT COUNT(1) FROM WMS_T_MODIFY_NOTICES WHERE BILL_NO=#{billno}")
    int selectMidefyBillNoNumber( @Param("billno") String billno);

    @Select("SELECT COUNT(1) FROM WMS_T_IN_NOTICES WHERE BILL_NO=#{billno}")
    int selectInBillNoNumber( @Param("billno") String billno);

    @Select("SELECT COUNT(1) FROM WMS_T_OUT_NOTICES WHERE BILL_NO=#{billno}")
    int selectOutBillNoNumber( @Param("billno") String billno);

    @UpdateProvider(type = WmsSqlProvider.class, method = "updateSql")
    int update(@Param("tableName") String tableName,
               @Param("setKeys") JSONObject setKeys,
               @Param("whereKeys") JSONObject whereKeys);

    @UpdateProvider(type = WmsSqlProvider.class, method = "updateSql")
    int update3(@Param("tableName") String tableName,
                @Param("setKeys") JSONObject setKeys,
                @Param("whereStr") String whereStr);
//
//    @InsertProvider(type = WmsSqlProvider.class, method = "insertSql")
//    int insert(@Param("tableName") String tableName,
//               @Param("insertKeys") JSONObject insertKeys);

    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
    List<HashMap> select(@Param("tableName") String tableName,
                         @Param("fields") String[] fields,
                         @Param("whereKeys") JSONObject whereKeys);

//    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
//    List<HashMap> select2(@Param("tableName") String tableName,
//                          @Param("fields") String[] fields,
//                          @Param("whereKeys") JSONObject whereKeys,
//                          @Param("order") String order,
//                          @Param("limit") String limit);

//    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
//    List<HashMap> select3(@Param("tableName") String tableName,
//                          @Param("fields") String[] fields,
//                          @Param("whereStr") String whereStr,
//                          @Param("order") String order,
//                          @Param("limit") String limit);

    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
    List<HashMap> select4(@Param("tableName") String tableName,
                          @Param("fields") String[] fields,
                          @Param("order") String order,
                          @Param("limit") String limit);
    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
    List<HashMap> select9(@Param("tableName") String tableName,
                          @Param("fields") String[] fields,
                          @Param("order") String order
                          );

    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
    List<HashMap> select8(@Param("tableName") String tableName,
                          @Param("fields") String[] fields,
                          @Param("whereStr") String whereStr);
//
//    @SelectProvider(type = WmsSqlProvider.class, method = "selectSql")
//    List<HashMap> select5(@Param("tableName") String tableName,
//                          @Param("fields") String[] fields,
//                          @Param("whereKeys") JSONObject whereKeys,
//                          @Param("order") String order);


    @UpdateProvider(type = WmsSqlProvider.class, method = "deleteSql")
    int delete(@Param("tableName") String tableName,
               @Param("whereKeys") JSONObject whereKeys);

    @UpdateProvider(type = WmsSqlProvider.class, method = "updateSqlOracle")
    int updateoracle(@Param("tableName") String tableName,
               @Param("setKeys") JSONObject setKeys,
               @Param("whereKeys") JSONObject whereKeys);

    @UpdateProvider(type = WmsSqlProvider.class, method = "updateSqlOracle")
    int updateoracle2(@Param("tableName") String tableName,
                @Param("setKeys") JSONObject setKeys,
                @Param("whereStr") String whereStr);

    @InsertProvider(type = WmsSqlProvider.class, method = "insertSqlOracle")
    int insert(@Param("tableName") String tableName, @Param("insertKeys") JSONObject insertKeys);

//    //根据bill_no删除调拨出库明细表的内容
//    @Delete("UPDATE WMS_T_OUT_NOTICES  t  set  t.BILL_NO=t.BILL_NO||'-1'  where t.bill_no=#{billNo}")
//    int delWmsOutNoticesItem(
//            String billNo
//
//    );
//
//    //根据bill_no删除调拨出库主表的内容
//    @Delete("DELETE FROM WMS_T_OUT_NOTICES WHERE BILL_NO=#{billNo}")
//    int delWmsOutNotices(String billNo);

}
